//-----------------------------------------------------------------------------
// File: EnumFormatter.cs
//
// Copyright (c) Dmitry Shuklin. All rights reserved.
//-----------------------------------------------------------------------------
using System;

namespace ObjectiveDraw.Platform.Serialization
{
	/// <summary>
	/// Summary description for EnumFormatter.
	/// </summary>
	public class EnumFormatter : IPropertyFormatter
	{
		public EnumFormatter()
		{
			//
			// TODO: Add constructor logic here
			//
		}
		#region IFieldFormatter Members

		public object SerializeValue(object value, object [] parameters)
		{
			return value==null?null:(object)((int)value);
		}

		public object DeserializeValue(object value, object [] parameters)
		{
			return value==null?null:System.Enum.ToObject((System.Type)parameters[0], (int)value);
		}

		#endregion
	}
}
